package com.example.courier.common.enums;

import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
 * @author qwert
 * @version 1.0.0
 * @create 2025/9/6 17:46
 **/
@Getter
public enum DeliveryStatus {
    DELIVERED("delivered"),
    IN_PROGRESS("in_progress"),
    PENDING("pending");

    private final String status;

    DeliveryStatus(String status) {
        this.status = status;
    }

    public static DeliveryStatus getDeliveryStatus(String status) {
        Optional<DeliveryStatus> result = Arrays.stream(values())
                .filter(e -> e.status.equals(status))
                .findFirst();

        if (result.isPresent()) {
            return result.get();
        } else {
            throw new RuntimeException("未知状态: " + status);
        }
    }
}
